package com.xx.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

import javax.xml.bind.DatatypeConverter;
import java.util.List;

public class HexStringToBytesDecoder extends MessageToMessageDecoder<String> {
    @Override
    protected void decode(ChannelHandlerContext ctx, String msg, List<Object> out) {
        // 将十六进制字符串转换为字节数组
        byte[] hexBytes = DatatypeConverter.parseHexBinary(msg);
        out.add(hexBytes);
    }
}